<%@page import="vlms.bean.Movie"  %>
<%@page import="java.util.*"  %>
<%@page import="java.text.*"  %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<script type="text/javascript">

function validate(){
    
    if(document.searchMovie.Search.value=="")
    {
 alert("Please select a category");
 document.searchMovie.Search.focus();
 return false;
    }
    if(document.searchMovie.searchByText.value=="")
    {
 alert("Please enter keyword to search");
 document.searchMovie.searchByText.focus();
 return false;
    }
   
   
    return true;
}
    </script>

<%@ include file="/title.html" %>
</head>
<body>
<table width="100%">
<%@ include file="/header.jsp" %>

<tr valign="top"><td align="center" height="300px">
<table width="100%">

<tr valign="top" height="50px">
<td align="center">
<%@ include file="/headerLinks.jsp" %>
</td>
</tr>
<tr><td align="center" height="40px" colspan="2" valign="top"><h3>Search Movies</h3></td></tr>
<% if(request.getAttribute("message") != null) { %>
<tr><td align="center" style="color:red"><%= request.getAttribute("message") %></td></tr>
<% } %>


<form name="searchMovie" method="post" action="SearchMovie" onsubmit="return validate();">
<tr>
<td colspan="2">
<table>
<tr><td>
    <SELECT name="searchCriteria" id ="Search">
        <OPTION VALUE="movieName">Name</OPTION>
        <OPTION VALUE="banner">Banner</OPTION>
        <OPTION VALUE="category">Category</OPTION>
    </SELECT>
</td>

<td><input type="text" name="searchByText" id="searchByText"></td>
</td>
<td><input type="submit" name="submit" value = "Search"></td>
</tr>
</table>
</td>
</tr>
</form>
<%if(null != request.getAttribute("MovieList")) { 
%>  
<tr>
    <td align="center">
    <table  width="70%" style="text-align:left">
        <tr>
            <td>No.</td>
            <td>Movie Name</td>
            <td>Banner</td>
            <td>Category</td>
            <td>Release Date</td>
            <td>Rent Amount</td>
            <td></td>
        </tr>
<% 


        Movie aMovie[] = (Movie[])request.getAttribute("MovieList");
if(null != aMovie && aMovie.length > 0) {
        for(int i=0;i<aMovie.length;i++) {
        	if(aMovie[i].getCopiesavailable() <= 0) {
        		continue;
        	}
        	Calendar c= aMovie[i].getReleasedate();
        	java.util.Date d=new java.util.Date(c.getTimeInMillis());
        	%>
        

    <form name="update_<%=aMovie[i].getMovieid()%>" action="AddMovieToCart" method="post">
        <tr>
            <td><%=i+1%></td>
            <td><%=aMovie[i].getMoviename() %></td>
            <td><%=aMovie[i].getMoviebanner() %></td>
            <td><%=aMovie[i].getCategory() %></td>
            <td>2011-12-12</td>
            <td><%=aMovie[i].getRentamount() %></td>
            
            <td>                
                <input type="submit" name="submit" value="Add to Cart">
                
                <input type="hidden" name="movieId" value="<%=aMovie[i].getMovieid() %>">
            </td>
            
        </tr>
    </form>     
<%      }
     }
}
        %>
    </table>
    </td>
</tr>


</table>
</td>
</tr>

<%@ include file="/bottom.html" %>
</table>
</body>
</html>